package com.wzgl.core.shop;

import java.util.ArrayList;
import java.util.List;

import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Page;
import com.wzgl.core.utils.StringUtils;

public class ShopTseqCode extends BaseShopTseqCode<ShopTseqCode> {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public static final ShopTseqCode dao = new ShopTseqCode();
	
	public ShopTseqCode findById(final String fid) {
		//后期使用缓存,前期不考虑
		return dao.doFindFirst("fid = ?", fid);
	}
	/***
	 * 根据序列号查询
	 * @param fsequence
	 * @return
	 */
	public ShopTseqCode findBySequence(final String fsequence) {
		//后期使用缓存,前期不考虑
		return dao.doFindFirst("fsequence = ?", fsequence);
	}
	
	public Page<ShopTseqCode> paginate(int pageNumber, int pageSize,String fpage,String userid) {
		String sql= " from tseqCode where 1 = 1";
		List<Object> agrs = new ArrayList<Object>();
		if(StringUtils.isNotEmpty(fpage)){
			sql += " and ftype = ?";
			agrs.add(fpage);
		}
		if(StringUtils.isNotEmpty(userid)){
			sql += " and fuserid = ? ";
			agrs.add(userid);
		}
		sql += " order by fcreateTime desc";
		return paginate(pageNumber, pageSize,"select *", sql,agrs.toArray());
	}
}
